export {chunk} from "lodash"
export const cloneDeep = <T>(value: T): T => {
    return JSON.parse(JSON.stringify(value));
};
export const last = <T>(array: Array<T>): T | undefined => {
    const lastArray = array.slice(array.length, array.length - 1);
    return lastArray.length ? lastArray[0] : undefined;
};
export const intersection = <T>(array1: Array<T>, array2: Array<T>): Array<T> => {
    const set1 = new Set(array1);
    const set2 = new Set(array2);
    return Array.from(set1).filter((x) => set2.has(x));
};
export const difference = <T>(array1: Array<T>, array2: Array<T>): Array<T> => {
    const set1 = new Set(array1);
    const set2 = new Set(array2);
    const newArr:Array<T> = [];
    set1.forEach(item=>{
        if(!set2.has(item)){
            newArr.push(item);
        }
    })
    return newArr
};

export const get = (obj: Object, path: string) => {
    return path.split(".").filter(Boolean).reduce((p, c) => {
        // @ts-ignore
        return p ? p[c] : undefined;
    }, obj);
};
